<template>
  <el-dialog title="新增用户" width="600px" :visible.sync="show" class="box">
    <el-form label-width="100px" :model="form" :rules="rules">
      <el-form-item label="用户名" prop="name">
        <el-input v-model="form.name" />
      </el-form-item>
      <el-form-item label="邮箱" prop="mailbox">
        <el-input v-model="form.mailbox" />
      </el-form-item>
      <el-form-item label="电话" prop="phone">
        <el-input v-model="form.phone" />
      </el-form-item>
      <el-form-item label="角色" prop="role">
        <el-select v-model="form.role">
          <el-option label="超级管理员" value="shanghai" />
          <el-option label="管理员" value="beijing" />
          <el-option label="老师" value="beijing" />
          <el-option label="学生" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="state">
        <el-select v-model="form.state">
          <el-option label="启用" value="shanghai" />
          <el-option label="禁用" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="用户备注">
        <el-input />
      </el-form-item>
    </el-form>
    <template #footer>
      <div style="text-align: center">
        <el-button @click="show = false">取消</el-button>
        <el-button type="primary" @click="addEvent">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script>
// import { userAdd } from '@/api/userList'
export default {
  data() {
    return {
      show: false,
      form: {
        name: '',
        mailbox: '',
        phone: '',
        role: '',
        state: ''
      },
      // 表单验证
      rules: {
        name: [{ required: true, message: '请输入活动名称', trigger: 'blur' }],
        mailbox: [
          { required: true, message: '请输入邮箱地址', trigger: 'blur' },
          {
            type: 'email',
            message: '请输入正确的邮箱地址',
            trigger: ['blur', 'change']
          }
        ],
        phone: [
          {
            required: true,
            message: '请输入手机号',
            trigger: ['blur', 'change']
          },
          {
            pattern:
              /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/,
            message: '请输入正确手机号格式',
            trigger: 'change'
          }
        ],
        role: [{ required: true, message: '请选择', trigger: 'change' }],
        state: [{ required: true, message: '请选择', trigger: 'change' }]
      }
    }
  },
  methods: {
    // 新增确定按钮处理函数
    addEvent() {
      console.log('确定')
    }
  }
}
</script>
<style lang="scss" scoped>
.box {
  ::v-deep .el-dialog__header {
    background-image: linear-gradient(to right,#01c4fa,#109afa);
    text-align: center;
  }
}
</style>
